using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 物料库存变动历史
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("PartsStockChange", "物料库存变动历史")]
public class PartsStockChange
{
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(ColumnName = "Id", ColumnDescription = "", IsPrimaryKey = true, IsIdentity = true)]
    public long Id { get; set; }

    /// <summary>
    /// 物料编码
    /// </summary>
    [SugarColumn(ColumnName = "PartNo", ColumnDescription = "物料编码", Length = 50)]
    [Required, MaxLength(50)]
    public string PartNo { get; set; } = string.Empty;

    /// <summary>
    /// 操作时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "操作时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 单据号
    /// </summary>
    [SugarColumn(ColumnName = "BillNo", ColumnDescription = "单据号", Length = 50)]
    [Required, MaxLength(50)]
    public string BillNo { get; set; } = string.Empty;

    /// <summary>
    /// 操作模块
    /// </summary>
    [SugarColumn(ColumnName = "ChgType", ColumnDescription = "操作模块")]
    public Guid ChgType { get; set; }

    /// <summary>
    /// 操作类型
    /// </summary>
    [SugarColumn(ColumnName = "Type", ColumnDescription = "操作类型")]
    public Guid Type { get; set; }

    /// <summary>
    /// 车间
    /// </summary>
    [SugarColumn(ColumnName = "Workshop", ColumnDescription = "车间")]
    public Guid Workshop { get; set; }

    /// <summary>
    /// 仓位
    /// </summary>
    [SugarColumn(ColumnName = "Location", ColumnDescription = "仓位")]
    public Guid Location { get; set; }

    /// <summary>
    /// 旧库存
    /// </summary>
    [SugarColumn(ColumnName = "StoreQtyChanging", ColumnDescription = "旧库存")]
    public decimal StoreQtyChanging { get; set; }

    /// <summary>
    /// 数量
    /// </summary>
    [SugarColumn(ColumnName = "num", ColumnDescription = "数量")]
    public decimal Num { get; set; }

    /// <summary>
    /// 批次号
    /// </summary>
    [SugarColumn(ColumnName = "BatchNumber", ColumnDescription = "批次号", Length = 10)]
    [MaxLength(10)]
    public string? BatchNumber { get; set; }

    /// <summary>
    /// 新库存
    /// </summary>
    [SugarColumn(ColumnName = "StoreQtyChanged", ColumnDescription = "新库存")]
    public decimal StoreQtyChanged { get; set; }

    /// <summary>
    /// 领用产线
    /// </summary>
    [SugarColumn(ColumnName = "To_Line", ColumnDescription = "领用产线")]
    public Guid? ToLine { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [SugarColumn(ColumnName = "Remark", ColumnDescription = "备注", Length = 200)]
    [MaxLength(200)]
    public string? Remark { get; set; }

    /// <summary>
    /// 操作人
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "操作人", Length = 20)]
    [Required, MaxLength(20)]
    public string CreateUser { get; set; } = string.Empty;

    /// <summary>
    /// 确认时间
    /// </summary>
    [SugarColumn(ColumnName = "ConTime", ColumnDescription = "确认时间")]
    public DateTime? ConTime { get; set; }

    /// <summary>
    /// ChgType (操作模块) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ChgType),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_ChgType { get; set; }

    /// <summary>
    /// Location (仓位) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Location),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Location { get; set; }

    /// <summary>
    /// To_Line (领用产线) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ToLine),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_To_Line { get; set; }

    /// <summary>
    /// Type (操作类型) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Type),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Type { get; set; }

    /// <summary>
    /// Workshop (车间) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Workshop),nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Workshop { get; set; }

    /// <summary>
    /// CreateUser (操作人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser),nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }
}